﻿using UnityEngine;
using System.Collections;
using System.Threading;

public class AniBean : AniBase {

	public CallBack complete;

	public AudioClip aniClip;
	
	public float clipDelaySecond;

	public override void playCallBack(CallBack callBack) {
		complete = callBack;
		playAniClip();
	}

	public virtual void playComplete() {
		if(complete != null) {
			complete();
			complete = null;
		}
	}

	protected virtual void playAniClip() {
		if(aniClip != null) {
			if(clipDelaySecond <= 0) {
				NGUITools.PlaySound(aniClip);
				
			} else {
				StartCoroutine(GameMonoUtils.getDelayCallBack(clipDelaySecond, ()=>{NGUITools.PlaySound(aniClip);}));
			}
		}
	}
}
